﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Globalization;
using System.IO;

namespace FileUpload
{
    public partial class FileUpload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
             
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            FileUploadMethod(FileUpload1, "uploadfiles");
        }

        private void FileUploadMethod(System.Web.UI.WebControls.FileUpload FileUpload2, string p)
        {
            if (FileUpload2.HasFile)
            {
                string dir = ConfigurationManager.AppSettings[p];
                string time = DateTime.Now.ToString("yyyyMMddHHmmss", new CultureInfo("zh-CHS"));
                string path = dir + time + FileUpload2.FileName;
                path = HttpContext.Current.Server.MapPath(path);
                FileUpload2.SaveAs(path);              
            }
            else
            {

            }
        }

        
    }
}